import "package:fluent_ui/fluent_ui.dart";
import "pages/form.dart";
import "pages/table.dart";
import "pages/dashboard.dart";

class RygAbc {
  int get numbers {
    return 0;
  }
}

class RygCde extends RygAbc {
  @override
  int get numbers {
    return 1;
  }
}

RygAbc abc = RygCde();

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return FluentApp(
      title: 'windows Demo',
      theme: ThemeData(
        // accentColor: Colors.yellow,
        //micaBackgroundColor: Colors.white,
        scaffoldBackgroundColor: Colors.white,
        visualDensity: VisualDensity.adaptivePlatformDensity,
        typography: const Typography.raw(
          caption: TextStyle(
            fontSize: 12,
            color: Colors.grey,
            fontWeight: FontWeight.normal,
          ),
        ),
        focusTheme: const FocusThemeData(
          glowFactor: 4.0,
        ),
      ),
      home: const MyHomePage(title: '我的一个测试程序'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int index = 0;
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return NavigationView(
      appBar: const NavigationAppBar(
        // leading: Icon(FluentIcons.align_justify),
        title: Text(' '),
        height: 10,
        // actions: Row(children: const [
        //   Icon(FluentIcons.close_pane),
        // ]),

        /// If automaticallyImplyLeading is true, a 'back button' will be added to
        /// app bar. This property can be overritten by [leading]
        automaticallyImplyLeading: false,
      ),
      pane: NavigationPane(
        indicator: const EndNavigationIndicator(),

        /// The current selected index
        selected: _currentIndex,
        items: [
          PaneItemHeader(header: const Text("演示菜单")),
          PaneItem(
            icon: const Icon(FluentIcons.form_library),
            title: const Text("表单"),
          ),
          PaneItem(
            icon: const Icon(FluentIcons.table),
            title: const Text('表格'),
          ),
          PaneItem(
            icon: const Icon(FluentIcons.b_i_dashboard),
            title: const Text("仪表盘"),
          ),
        ],
        autoSuggestBox: AutoSuggestBox(
          controller: TextEditingController(),
          items: const ['Item 1', 'Item 2', 'Item 3', 'Item 4'],
        ),
        autoSuggestBoxReplacement: const Icon(FluentIcons.search),
        footerItems: [
          PaneItemSeparator(),
          PaneItem(
            icon: const Icon(FluentIcons.settings),
            title: const Text('Settings'),
          ),
        ],

        /// Called whenever the current index changes
        onChanged: (i) => setState(() => _currentIndex = i),
        displayMode: PaneDisplayMode.top,
      ),
      content: NavigationBody(
        index: _currentIndex,
        children: const [FormPage(), TablePage(), DashBoardPage()],
      ),
    );
  }
}
